package test2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2025-02-01
 * Time: 12:16
 */
class Circle implements Shape{
    public Color color;
    public Circle(Color color){
        this.color = color;
    }
    public void draw(){
        System.out.println("画一个矩形");
        color.applyColor();
    }
}
public class Test4 {
    public static void main(String[] args) {

        Shape shape = new Circle(new Color() {
            @Override
            public void applyColor() {
                System.out.println("添加红色");
            }
        });
        shape.draw();
    }
}
